package com.vdong.interactive.course.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageInfo;
import com.vdong.interactive.course.entity.dto.CourseCategoryDTO;
import com.vdong.interactive.course.entity.dto.PeddleChoiceCourseListDTO;
import com.vdong.interactive.course.service.CourseCategoryService;
import com.vdong.kpay.basics.dubbo.api.backend.CourseCatalogService;
import com.vdong.kpay.basics.dubbo.api.backend.CourseMainService;
import com.vdong.kpay.basics.dubbo.pojo.backend.CourseCatalog;
import com.vdong.kpay.basics.dubbo.pojo.backend.CourseMain;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

//@Service(version = "1.0.0")
@org.springframework.stereotype.Service
public class CourseCategoryServiceImpl implements CourseCategoryService {

    @Reference(version = "1.0.0")
    private CourseCatalogService courseCatalogService;

    public List<CourseCategoryDTO> getCourseCategoryList(Long parentId){
        List<CourseCatalog> catalogList = null;
        List<CourseCategoryDTO> categoryDTOList = new ArrayList<>();
        if (parentId == null || parentId.compareTo(0L) == 0){
            catalogList = courseCatalogService.findSaasCourseCatalog();


        }else{
            catalogList = courseCatalogService.findSaasSecondCatalogName(parentId);
        }

        catalogList.forEach(e -> {
            CourseCategoryDTO courseCategoryDTO = new CourseCategoryDTO();
            courseCategoryDTO.setCatalogUrl(e.getCatalogUrl());
            courseCategoryDTO.setId(e.getId());
            courseCategoryDTO.setName(e.getName());
            courseCategoryDTO.setNumber(e.getNumber());
            courseCategoryDTO.setParentId(e.getParentId());
            courseCategoryDTO.setSort(e.getSort());
            courseCategoryDTO.setType(e.getType());
            categoryDTOList.add(courseCategoryDTO);
        });

        return categoryDTOList;
    }
}
